<template>
  <FormView not-form form-width="100%">
    <div class="color-box">
      <div v-for="item in colors" :key="item.value" class="color-item-wrapper">
        <div class="color-item" @click="copy(item)">
          <div :style="{ backgroundColor: item.value }" class="color-preview"></div>
          <div class="color-info">
            <p :title="item.name" class="color-name">{{ item.name }}</p>
            <p class="color-value">{{ item.value }}</p>
          </div>
        </div>
      </div>
    </div>
  </FormView>
</template>

<script>
  import { copyData } from '@/util/clipboard'

  export default {
    name: 'Color',
    data() {
      return {
        colors: [
          {
            name: '$theme-color',
            value: '#409eff'
          },
          {
            name: '$borderColor',
            value: '#e4e7ed'
          },
          {
            name: '$infoColor',
            value: '#909399'
          },
          {
            name: '$successColor',
            value: '#80d954'
          },
          {
            name: '$warningColor',
            value: '#e6a23c'
          },
          {
            name: '$dangerColor',
            value: '#f56c6c'
          },
          {
            name: '$chatBorderBottomColor',
            value: '#e0e0e0'
          },
          {
            name: '$msgColor',
            value: '#8890a4'
          },
          {
            name: '$bdColor',
            value: '#353F57'
          },
          {
            name: '$lightBlue',
            value: '#EAF2FD'
          },
          {
            name: '$lightGray2',
            value: '#FCFCFC'
          },
          {
            name: '$maskBackgroundColor',
            value: 'rgba(27, 31, 35, 0.5)'
          },
          {
            name: '$borderColor',
            value: '#D7DAE0'
          },
          {
            name: '$lightGray',
            value: '#F2F3F7'
          },
          {
            name: '$bgColor',
            value: '#F8F9FB'
          },
          {
            name: '$bgColor',
            value: '#E4E5F4'
          }
        ]
      }
    },
    methods: {
      copy: item => copyData(item)
    }
  }
</script>

<style lang="scss" scoped>
  .color-box {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    min-height: 100%;
    padding: 5px;
    background-color: white;
  }

  .color-item-wrapper {
    display: inline-block;
    flex: 1;
    width: 12.5%;
    min-width: 12.5%;
    max-width: 12.5%;
    height: 200px;
    max-height: 200px;
    padding: 5px;
  }

  .color-item {
    position: relative;
    height: 100%;
    border: 1px solid gainsboro;
    transition: transform 0.2s linear;

    &:hover {
      border-color: white;
      box-shadow:
        0 0 6px rgba(0, 0, 0, 0.2),
        0 4px 6px rgba(0, 0, 0, 0.2);
      transform: translate3d(0, -3px, 0);
      cursor: pointer;
    }

    .color-preview {
      height: 60%;
    }

    .color-info {
      height: 40%;
      padding: 8px;

      .color-name {
        color: #232222;
        font-weight: 700;

        @include ellipsis(1);
      }

      .color-value {
        margin-top: 4px;
        font-size: 0.9em;
      }
    }
  }

  /* 3 */
  @media screen and (min-width: 0) and (max-width: 599px) {
    .color-item-wrapper {
      flex: 1;
      width: 33.3333%;
      min-width: 33.3333%;
      max-width: 33.3333%;
      height: 200px;
      padding: 4px;
    }
  }

  /* 4 */
  @media screen and (min-width: 600px) and (max-width: 805px) {
    .color-item-wrapper {
      flex: 1;
      width: 25%;
      min-width: 25%;
      max-width: 25%;
      height: 200px;
      padding: 4px;
    }
  }

  /* 5 */
  @media screen and (min-width: 806px) and (max-width: 957px) {
    .color-item-wrapper {
      flex: 1;
      width: 20%;
      min-width: 20%;
      max-width: 20%;
      height: 200px;
      padding: 4px;
    }
  }

  /* 6 */
  @media screen and (min-width: 960px) and (max-width: 1250px) {
    .color-item-wrapper {
      flex: 1;
      width: 16.6666%;
      min-width: 16.6666%;
      max-width: 16.6666%;
      height: 200px;
      padding: 4px;
    }
  }
</style>
